<template>
  <div class="app-container">
    <label class="title" style="font-size: 20px;color: rgba(0,0,0,.85);font-weight: 600;line-height: 32px">仲裁管理</label>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="学校" prop="zxdm">
        <el-select v-model="queryParams.zxdm" placeholder="请选择" clearable filterable size="small">
          <el-option
            v-for="dict in zxmcList"
            :key="dict.zxdm"
            :label="dict.zxmc"
            :value="dict.zxdm"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="班级" prop="bjdm">
        <el-select v-model="queryParams.bjdm" placeholder="请选择" clearable size="small">
          <el-option
            v-for="dict in bjdmList"
            :key="dict.bjdm"
            :label="dict.bjdm"
            :value="dict.bjdm"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="姓名" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入姓名"/>
      </el-form-item>
      <el-form-item label="性别" prop="gender">
        <el-select v-model="queryParams.gender" placeholder="请选择" clearable size="small" class="selectWidth">
          <el-option
            v-for="dict in dict.type.sys_user_sex"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="准考号" prop="zkh">
        <el-input v-model="queryParams.zkh" placeholder="请输入准考号"/>
      </el-form-item>
      <el-form-item label="原考试时间" prop="startTime" label-width="90">
        <el-date-picker clearable size="small"
                        v-model="queryParams.startTime"
                        type="datetime"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        placeholder="选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="" prop="endTime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.endTime"
                        type="datetime"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        placeholder="选择结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:arbitration:add']"
        >新增仲裁
        </el-button>
      </el-col>
    </el-row>
    <el-table v-loading="loading" :data="candidateList">
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{ scope.$index + (queryParams.pageNum - 1) * queryParams.pageSize + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="准考号" align="center" prop="zkh"/>
      <el-table-column label="姓名" align="center" prop="name"/>
      <el-table-column label="性别" align="center" prop="gender">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.gender"/>
        </template>
      </el-table-column>
      <el-table-column label="中学代码" align="center" prop="zxdm"/>
      <el-table-column label="中学名称" align="center" prop="zxmc"/>
      <el-table-column label="班级代码" align="center" prop="bjdm"/>
      <el-table-column label="项目名称" align="center" prop="projectname"/>
      <el-table-column label="考点" align="center" prop="placename"/>
      <el-table-column label="设备名称" align="center" prop="devName"/>
      <el-table-column label="原考试时间" align="center" prop="alongTime" width="95"/>
      <el-table-column label="原始成绩" align="center" prop="alongGrade"/>
      <el-table-column label="原始分数" align="center" prop="alongFraction"/>
      <el-table-column label="状态" align="center" prop="status"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.status=='未处理'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleDetail(scope.row)"
            v-hasPermi="['business:arbitration:edit']"
          >处理
          </el-button>
          <el-button
            v-if="scope.row.status=='已处理'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleShowDetail(scope.row)"
            v-hasPermi="['business:arbitration:query']"
          >查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 提交仲裁对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="确定考生" prop="zkh">
          <el-input v-model="form.zkh" placeholder="请输入准考号">
            <el-button slot="append" icon="el-icon-search" @click="handleChoose">选择</el-button>
          </el-input>
        </el-form-item>
        <el-collapse v-model="activeNames">
          <el-collapse-item title="考生信息" name="1">
            <table id="table">
              <tr>
                <td>
                  <el-form-item label="姓名" prop="name">
                    <el-input v-model="form.name" placeholder="请输入姓名" disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="性别" prop="gender">
                    <el-select v-model="form.gender" placeholder="请选择" clearable size="small" class="selectWidth"
                               style="width: 180px;" disabled="disabled">
                      <el-option
                        v-for="dict in dict.type.sys_user_sex"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td rowspan="4" height="200px">
                  <el-input v-model="form.zp" style="display: none"/>
                  <el-form-item label="照片" prop="zp">
                    <el-image style="width: 160px; height: 200px" :src="form.zpStr"></el-image>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="准考号" prop="zkh">
                    <el-input v-model="form.zkh" placeholder="请输入准考号" oninput="value=value.replace(/[^0-9.]/g,'')"
                              disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="建档号" prop="jdh">
                    <el-input v-model="form.jdh" placeholder="请输入建档号" oninput="value=value.replace(/[^0-9.]/g,'')"
                              disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="中学名称" prop="zxmc">
                    <el-select v-model="form.zxmc" filterable placeholder="请选择" clearable size="small"
                               style="width: 180px;" disabled="disabled">
                      <el-option
                        v-for="dict in zxmcList"
                        :key="dict.zxmc"
                        :label="dict.zxmc"
                        :value="dict.zxdm">
                        <span style="float: left">{{ dict.zxmc }}</span>
                        <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.zxdm }}</span>
                      </el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="班级代码" prop="bjdm">
                    <el-input v-model="form.bjdm" placeholder="请输入班级代码" disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="区域" prop="qy">
                    <el-select v-model="form.qy" filterable placeholder="请选择" clearable size="small"
                               class="selectWidth" style="width: 180px;" disabled="disabled">
                      <el-option
                        v-for="dict in qyList"
                        :key="dict.n"
                        :label="dict.n"
                        :value="dict.v"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="身份证" prop="sfzh">
                    <el-input v-model="form.sfzh" placeholder="请输入身份证" disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="联系电话" prop="lxdh">
                    <el-input v-model="form.lxdh" placeholder="请输入联系电话" disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="平时分" prop="usualResults">
                    <el-input-number v-model="form.usualResults" placeholder="请输入平时分" :min="0" :max="5"
                                     style="width: 180px;" disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="必测项目" prop="lxdh">
                    <el-input v-model="form.bctyxm" placeholder="必测考试项目" disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="选测项目1" prop="usualResults">
                    <el-input v-model="form.xctyxm1" placeholder="选测考试项目1" :min="0" :max="5"
                              style="width: 180px;" disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="选测项目2" prop="lxdh">
                    <el-input v-model="form.xctyxm2" placeholder="选测考试项目2" disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>

                </td>
              </tr>
            </table>
          </el-collapse-item>
        </el-collapse>
        <el-form-item label="仲裁项目" prop="examProjectId">
          <el-select v-model="form.examProjectId" placeholder="请选择"  size="small" class="selectWidth"
                     @change="changProject">
            <el-option
              v-for="dict in projectIdLists"
              :key="dict.id"
              :label="dict.name"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="原成绩" prop="lxdh">
          <el-input v-model="form.alongGrade" disabled style="width: 100px"/>
          <span>{{ form.resultUnit }}</span>
        </el-form-item>
        <el-form-item label="原分数" prop="lxdh">
          <el-input v-model="form.alongFraction" disabled style="width: 100px"/>
        </el-form-item>
        <el-form-item label="考试日期" prop="alongTime">
          <el-input v-model="form.alongTime" disabled style="width: 200px"/>
        </el-form-item>
        <el-form-item label="原因说明" prop="reson">
          <el-input type="textarea" v-model="form.reson" placeholder="请输入原因说明"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 处理仲裁对话框 -->
    <el-dialog :title="handleTitle" :visible.sync="handleOpen" width="900px" append-to-body>
      <el-form ref="form2" :model="form2" :rules="rules2" label-width="90px">
        <el-collapse v-model="activeNames2">
          <el-collapse-item title="考生信息" name="1">
            <table id="table2">
              <tr>
                <td>
                  <el-form-item label="姓名" prop="name">
                    <el-input v-model="form2.name" placeholder="请输入姓名" disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="性别" prop="gender">
                    <el-select v-model="form2.gender" placeholder="请选择" clearable size="small" class="selectWidth"
                               style="width: 180px;" disabled="disabled">
                      <el-option
                        v-for="dict in dict.type.sys_user_sex"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td rowspan="4" height="200px">
                  <el-input v-model="form2.zp" style="display: none"/>
                  <el-form-item label="照片" prop="zp">
                    <el-image style="width: 160px; height: 200px" :src="form2.zpStr"></el-image>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="准考号" prop="zkh">
                    <el-input v-model="form2.zkh" placeholder="请输入准考号" oninput="value=value.replace(/[^0-9.]/g,'')"
                              disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="建档号" prop="jdh">
                    <el-input v-model="form2.jdh" placeholder="请输入建档号" oninput="value=value.replace(/[^0-9.]/g,'')"
                              disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="中学名称" prop="zxmc">
                    <el-select v-model="form2.zxmc" filterable placeholder="请选择" clearable size="small"
                               style="width: 180px;" disabled="disabled">
                      <el-option
                        v-for="dict in zxmcList"
                        :key="dict.zxmc"
                        :label="dict.zxmc"
                        :value="dict.zxdm">
                        <span style="float: left">{{ dict.zxmc }}</span>
                        <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.zxdm }}</span>
                      </el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="班级代码" prop="bjdm">
                    <el-input v-model="form2.bjdm" placeholder="请输入班级代码" disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="区域" prop="qy">
                    <el-select v-model="form2.qy" filterable placeholder="请选择" clearable size="small"
                               class="selectWidth" style="width: 180px;" disabled="disabled">
                      <el-option
                        v-for="dict in qyList"
                        :key="dict.n"
                        :label="dict.n"
                        :value="dict.v"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="身份证" prop="sfzh">
                    <el-input v-model="form2.sfzh" placeholder="请输入身份证" disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="联系电话" prop="lxdh">
                    <el-input v-model="form2.lxdh" placeholder="请输入联系电话" disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="平时分" prop="usualResults">
                    <el-input-number v-model="form2.usualResults" placeholder="请输入平时分" :min="0" :max="5"
                                     style="width: 180px;" disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="必测项目" prop="lxdh">
                    <el-input v-model="form2.bctyxm" placeholder="必测考试项目" disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="选测项目1" prop="usualResults">
                    <el-input v-model="form2.xctyxm1" placeholder="选测考试项目1" :min="0" :max="5"
                              style="width: 180px;" disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="选测项目2" prop="lxdh">
                    <el-input v-model="form2.xctyxm2" placeholder="选测考试项目2" disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>
                </td>
              </tr>
            </table>
          </el-collapse-item>
          <el-collapse-item title="仲裁申请信息" name="2">
            <table>
              <tr>
                <td>
                  <el-form-item label="考点" prop="placename">
                    <el-input v-model="form2.placename" disabled="disabled"/>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="考试项目" prop="projectname">
                    <el-input v-model="form2.projectname" disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="原始成绩" prop="result">
                    <el-input v-model="form2.alongGrade" disabled="disabled" style="width: 100px"/>
                    <span>{{ form2.resultUnit }}</span>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="原始分数" prop="fraction">
                    <el-input v-model="form2.alongFraction" disabled="disabled"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td colspan="2">
                  <el-form-item label="原因说明" prop="reson">
                    <el-input type="textarea" v-model="form2.reson" placeholder="请输入原因说明" disabled="disabled"/>
                  </el-form-item>
                </td>
                <td></td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="处理意见" prop="state">
                    <el-select v-model="form2.state" placeholder="请选择处理意见">
                      <el-option label="同意" value="1">同意</el-option>
                      <el-option label="不同意" value="0">不同意</el-option>
                    </el-select>
                  </el-form-item>
                </td>
                <td>
                  <el-form-item label="修改成绩" prop="fraction">
                    <el-input-number v-model="form2.newGrade" :min="0" :precision="2" @change="computeFraction()"/>
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="修改后分数" prop="afterFraction">
                    <el-input v-model="form2.newFraction" disabled/>
                  </el-form-item>
                </td>
                <td>

                </td>
              </tr>
              <tr>
                <td colspan="2">
                  <el-form-item label="意见描述" prop="opinion">
                    <el-input type="textarea" v-model="form2.opinion" placeholder="请输入意见描述"/>
                  </el-form-item>
                </td>
              </tr>
            </table>
          </el-collapse-item>
          <el-collapse-item title="仲裁凭证" name="3">
            <el-button type="primary" @click="getVideo">获取录像</el-button>
            <el-button type="primary" @click="getPicture">获取轨迹图</el-button>
          </el-collapse-item>

          <el-collapse-item title="录像列表" name="4">
            <el-table v-loading="loading" :data="videoList">
              <el-table-column label="序号" type="index" align="center">
                <template slot-scope="scope">
                  <span>{{scope.$index+(query.pageNum-1)*query.pageSize+1}}</span>
                </template>
              </el-table-column>
              <el-table-column label="创建时间" align="center" prop="createTime">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    icon="el-icon-see"
                    @click="look(scope.row)"
                  >查看
                  </el-button>
                </template>
              </el-table-column>
            </el-table>

            <pagination
              v-show="total1>0"
              :total="total1"
              :page.sync="query.pageNum"
              :limit.sync="query.pageSize"
              @pagination="getVideoList"
            />
          </el-collapse-item>

          <el-collapse-item title="轨迹图列表" name="5">
            <el-table v-loading="loading" :data="traceList">
              <el-table-column label="序号" type="index" align="center">
                <template slot-scope="scope">
                  <span>{{scope.$index+(queryTrace.pageNum-1)*queryTrace.pageSize+1}}</span>
                </template>
              </el-table-column>
              <el-table-column label="创建时间" align="center" prop="createTime">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    icon="el-icon-see"
                    @click="look(scope.row)"
                  >查看
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <pagination
              v-show="total2>0"
              :total="total2"
              :page.sync="queryTrace.pageNum"
              :limit.sync="queryTrace.pageSize"
              @pagination="getTraceList"
            />
          </el-collapse-item>
        </el-collapse>
      </el-form>
      <div slot="footer" id="clid" class="dialog-footer">
        <el-button type="primary" @click="submitForm2">确 定</el-button>
        <el-button @click="cancel2">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 选择考生 -->
    <el-dialog :title="chooseCandidate.dialogTitle" :visible.sync="chooseCandidate.dialogSync" width="800px"
               append-to-body>
      <candidateInfo v-on:listenToChildEvent="listenClient"></candidateInfo>
    </el-dialog>
  </div>
</template>
<style>
.selectWidth {
  width: 207.44px;
}

.candidate-item {
  width: 400px;
}

.photo {
  width: 200px;
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: 0.5em;
  color: rgba(0, 0, 0, .85);
  font-weight: 500;
}
</style>
<script>
import {
  addArbitration,
  getResult,
  listArbitration,
  listArbitrationNew,
  updateArbitration,
  getRequest,
  listVideos,
  listTrace
} from '@/api/business/arbitration/arbitration'
import { examProjectsList, schoolClass } from '@/api/business/candidate/candidate'
import { listSchool } from '@/api/business/school/school'

import candidateInfo from '@/views/business/candidate/info'
import { getSuZhouQuYu } from '@/api/area'
import { computeFraction } from '@/api/business/examSummaryResult/examSummaryResult'

export default {
  name: 'candidateList',
  components: {
    candidateInfo
  },
  dicts: ['sys_user_sex', 'pictureFlag'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      total1: 0,
      total2: 0,
      // 考生表格数据
      candidateList: [],
      // 弹出层标题
      title: '',
      handleTitle: '',
      detailTitle: '',
      updateTitle: '',
      // 是否显示弹出层
      open: false,
      handleOpen: false,
      detailOpen: false,
      updateOpen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        zxdm: null,
        bjdm: null,
        pictureFlag: null
      },
      // 表单参数
      form: {},
      form2: {},
      // 表单校验
      rules: {
        zkh: [
          { required: true, message: '准考号不能为空', trigger: 'blur' }
        ],
        examProjectId: [
          { required: true, message: '仲裁项目不能为空', trigger: 'blur' }
        ],
        reson: [
          { required: true, message: '原因不能为空', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '密码不能为空', trigger: 'blur' }
        ]
      },
      rules2: {
        state: [
          { required: true, message: '处理意见不能为空', trigger: 'blur' }
        ],
        fraction: [
          { required: true, message: '修改成绩不能为空', trigger: 'blur' }
        ]
      },
      zxmcList: [],
      bjdmList: [],
      pictureFlagList: [],
      projectIdList: [],
      projectIdLists: [],
      doUpload: '',
      chooseCandidate: {
        dialogTitle: '',
        dialogSync: false
      },
      activeNames: ['1'],
      activeNames2: ['1', '2', '3'],
      qyList: [],
      query: {
          pageNum: 1,
          pageSize: 10,
          id: null
      },
      videoList:[],
      traceList:[],
      queryTrace: {
          pageNum: 1,
          pageSize: 10,
          id: null
      },
    }
  },
  created() {
    this.getList()
    listSchool().then(response => {
      this.zxmcList = response.rows
    })
    schoolClass().then(response => {
      this.bjdmList = response.data
    })

    getSuZhouQuYu().then(response => {
      this.qyList = response.data
    })
  },
  methods: {
    getProjectList() {
      examProjectsList().then(response => {
        this.projectIdList = response.data
      })
    },
    /** 查询考生列表 */
    getList() {
      this.loading = true
      listArbitrationNew(this.queryParams).then(response => {
        const records = response.rows
        this.candidateList = records
        this.total = response.total
        this.loading = false
      })
    },
      /** 查询录像列表 */
      getVideoList() {
          this.loading = true
          listVideos(this.query).then(result => {
              this.videoList = result.rows;
              this.total1 = result.total
              this.loading = false
          })
      },
      /** 查询轨迹图列表 */
      getTraceList() {
          this.loading = true
          listTrace(this.query).then(result => {
              this.traceList = result.rows;
              this.total2 = result.total
              this.loading = false
          })
      },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 取消按钮
    cancel2() {
      this.handleOpen = false
      this.reset()
    },
    // 取消按钮
    cancel3() {
      this.updateOpen = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        zkh: null,
        jdh: null,
        name: null,
        gender: null,
        zxdm: null,
        zxmc: null,
        bjdm: null,
        bctyxm: null,
        xctyxm1: null,
        xctyxm2: null,
        zp: null,
        version: null,
        gmtCreated: null,
        gmtModified: null,
        isDeleted: null,
        picture: null,
        printTimes: null,
        pictureFlag: null,
        usualResults: null
      }
      this.query.pageNum = 1;
      this.query.pageSize = 10;
      this.queryTrace.pageNum = 1;
      this.queryTrace.pageSize = 10;
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    /** 处理按钮操作 */
    handleDetail(row) {
      this.reset()
      this.form2 = row
      this.form2.gender = this.form2.gender.toString()
      this.handleOpen = true
      this.handleTitle = '处理'
      let data = {
        ksId: row.id.toString(),
        projectId: row.project.toString()
      }
      console.log(data);
      let self = this
      getResult(data).then(response => {
        if (200 == response.code) {
          self.form2.alongGrade = response.data.result
          self.form2.resultUnit = response.data.resultUnit
        }
      })
      document.getElementById('clid').style = 'display:block'
      this.getProjectList()
      this.query.id = row.arid
      this.getVideoList()
      this.queryTrace.id = row.arid
      this.getTraceList()
    },
    /** 详情按钮操作 */
    handleShowDetail(row) {
      this.reset()
      this.form2 = row
      this.handleOpen = true
      this.handleTitle = '查看'
      document.getElementById('clid').style = 'display:none'
      this.getProjectList()
      this.query.id = row.arid
      this.getVideoList()
      this.queryTrace.id = row.arid
      this.getTraceList()
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (null == this.form.examProjectId || '' == this.form.examProjectId) {
            this.$modal.msgSuccess('请选择已考项目')
            return
          }
          const data = {}
          data.project = this.form.examProjectId
          data.candidateId = this.form.id
          data.zkh = this.form.zkh
          data.alongGrade = this.form.alongGrade
          data.alongFraction = this.form.alongFraction
          data.zkh = this.form.zkh
          data.reson = this.form.reson
          data.alongTime = this.form.alongTime
          data.resultId = this.form.resultId
          data.devName = this.form.devName
          addArbitration(data, this.form.id).then(response => {
            if (response.code === 200) {
              this.$modal.msgSuccess('申请成功')
              this.open = false
              this.getList()
            }
            this.$modal.msgSuccess(response.msg)
          })
        }
      })
    },
    /** 处理按钮 */
    submitForm2() {
      this.$refs['form2'].validate(valid => {
        if (valid) {
          if (this.form2.id != null) {
            const data = {}
            data.id = this.form2.arid
            data.zkh = this.form2.zkh
            data.newGrade = this.form2.newGrade
            data.status = this.form2.state
            data.opinion = this.form2.opinion
            data.pointId = this.form2.piontId
            data.project = this.form2.project
            updateArbitration(data, this.form.arid).then(response => {
              if (response.code === 200) {
                this.$modal.msgSuccess('申请成功')
                this.handleOpen = false
                this.getList()
              }
              this.$modal.msgSuccess(response.msg)
            })
          }
        }
      })
    },
    /** 选择仲裁项目切换 */
    changProject(value) {
      let self = this
      let data = {
        ksId: self.form.id,
        projectId: value
      }
      getResult(data).then(response => {
          this.$forceUpdate()
        console.log(response);
        if (200 == response.code) {
            self.form.alongGrade = response.data.result
            self.form.resultUnit = response.data.resultUnit
            self.form.alongFraction = response.data.fraction
            self.form.alongTime = response.data.gmtCreated
            self.form.resultId = response.data.id
            self.form.devName = response.data.devName
        }
      }).catch(resp => {
          this.$forceUpdate()
          self.form.alongGrade = 0.0
          self.form.alongFraction = 0.0
          self.form.examProjectId = null
          self.form.alongTime = null
          self.form.resultId = null
          self.form.devName = null
      })
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '新增仲裁'
      this.getProjectList()
    },
    handleChoose() {
      this.chooseCandidate.dialogSync = true
      this.chooseCandidate.dialogTitle = '选择考生'
    },
    /** 选择器监听事件 */
    listenClient(data) {
      this.chooseCandidate.dialogSync = false
      this.form = data
      let projectLists = this.projectIdList
      //监听考生可以仲裁的体育项目
      let projectList = []
      for (var i = 0; i < projectLists.length; i++) {
        if (this.projectIdList[i].name == data.bctyxm) {
          projectList.push(projectLists[i])
        } else if (this.projectIdList[i].name == data.xctyxm1) {
          projectList.push(projectLists[i])
        } else if (this.projectIdList[i].name == data.xctyxm2) {
          projectList.push(projectLists[i])
        }
      }
      this.projectIdLists = projectList
    },
    //计算修正后成绩
    computeFraction() {
      if (this.form2.newGrade != null && null != this.form2.project) {
        const data = {
          ksId: this.form2.id,
          examId: this.form2.project,
          result: this.form2.newGrade
        }
        computeFraction(data).then(response => {
          if (response.data.status === 'success') {
            this.form2.newFraction = response.data.data.cj
          } else {
            this.$modal.msgError(response.data.message)
          }
        })
      }
    },
    //获取视频
    getVideo(){
      let arid=this.form2.arid
      console.log(arid);
      var query={
        id:arid,
        type:'1'
      }
      getRequest(query).then(response => {
        console.log(response);
        this.$modal.msgSuccess("获取视频成功，等待设备上传");
      })
    },
    //获取照片
    getPicture(){
      let arid=this.form2.arid
      var query={
        id:arid,
        type:'2'
      }
      getRequest(query).then(response => {
        console.log(response);
        this.$modal.msgSuccess("获取轨迹图成功，等待设备上传");
      })
    },
    //查看录像
     look(row){
         window.open(row.path)
     }
  }
}
</script>
